import axios from 'axios'

axios.defaults.baseURL = '/api';

axios.interceptors.response.use((res) => {
    return res.data
}, error => {
    return Promise.reject(error)
})

//轮播
export function getBanner() {
    return axios.get('/banner')
}

//推荐歌单
export function personalized(limit) {
    return axios.get('/personalized?limit=' + limit)
}

//最新音乐
export function newsong() {
    return axios.get('/personalized/newsong')
}

//推荐 mv
export function mv() {
    return axios.get('/personalized/mv')
}
//点击播放mv
// export function playMV(id) {
//     return axios.get('/song/url?id=' + id)
// }

//精品歌单
export function highquality(limit, cat) {
    return axios.get(`/top/playlist/highquality?limit=${limit}&cat=${cat}`)
}

//推荐歌单列表
export function playlist(limit, cat, offset) {
    return axios.get(`/top/playlist/?limit=${limit}&cat=${cat}&offset=${offset}`)
}

//left最新音乐
export function leftSongs(type) {
    return axios.get(`/top/song?type=${type}`)
}
//播放 音乐mv 公用
// export function playMusic(id) {
//     return axios.get(`/song/url?id=${id}`)
// }
export const playMusic = (id) => {
    return axios.get(`/song/url?id=${id}`)
}

//left mv
export function MV(area, type, order, limit, offset) {
    return axios.get(`/mv/all?area=${area}&type=${type}&order=${order}&limit=${limit}&offset=${offset}`)
}

//result 
export function Result(keywords, limit, offset, type) {
    return axios.get(`/search?keywords=${keywords}&limit=${limit}&offset=${offset}&type=${type}`)
}

//歌单详情
export function PlayDetail(id) {
    return axios.get(`/playlist/detail?id=${id}`)
}
//歌单评论
export function Hot(id, type) {  //热门评论
    return axios.get(`/comment/hot?id=${id}&type=${type}`)
}
export function NewHot(id, limit, offset) {   //最新评论
    return axios.get(`/comment/playlist?id=${id}&limit=${limit}&offset=${offset}`)
}

//mv地址
export function MVURL(id) {
    return axios.get(`/mv/url?id=${id}`)
}
//相似mv
export function MVSIMI(id) {
    return axios.get(`/simi/mv?mvid=${id}`)
}
//mvdetail
export function MVDetail(id) {
    return axios.get(`/mv/detail?mvid=${id}`)
}
//评论mv
export function MVcomment(id, limit, offset) {
    return axios.get(`/comment/mv?id=${id}&limit=${limit}&offset=${offset}`)
}
